from flask import Flask, request, jsonify, render_template
from flask_cors import CORS

app = Flask(__name__)
CORS(app)  # 启用CORS支持

# 添加首页路由
@app.route('/', methods=['GET'])
def index():
    return render_template('index.html')

@app.route('/send', methods=['POST'])
def receive_message():
    data = request.get_json()
    message = data.get('message', '')
    return jsonify({'message': f'收到消息: {message}'})

if __name__ == '__main__':
    app.run(debug=True, host='127.0.0.1', port=5000) 